<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>06-Array.from()</title>
</head>

<body>
    <ul>
        <li>黑色幽默</li>
        <li>黑色毛衣</li>
        <li>七里香</li>
        <li>发如雪</li>
    </ul>
    <script>
        // 1. Array.from(参数1，参数2):伪数组转化为数组
        //  参数1  是对象

        function sum() {
            let result = Array.from(arguments);
            console.log(result instanceof Array);  // true
            result.push("张飞");
            console.log(result);  // [1, 2, 3, 4, 5, '张飞']
        }
        sum(1, 2, 3, 4, 5);

        // 2. 参数2是函数，可以对数组中的每一个元素继续操作
        let lis = document.querySelectorAll("li");
        lis = Array.from(lis, (item, index) => {
            console.log(item, index);
            return item + 123;
        });
        lis.push('冰女');
        console.log(lis);

    </script>
</body>

</html>